<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head th:replace="common/header::common_head"></head>
<link rel="stylesheet" href="../bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
<link href="../dist/css/datePicker.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">

<title>采购退货单</title>
<style>
    table, td, th
    {
        border:1px ;
        text-align: center;
    }
    th
    {
        font-size:1.1em;
    }
    td
    {
        height:50px;
    }
    .calendar-item {
        position: absolute;
        cols: 3;
        rows: 1;
        height: 27px;
        width: 100px;
        padding-left: 10px;
        border: 1px solid #ccc;
        border-radius: 2px;
    }
</style>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <div th:replace="common/LeftCommon::common_top_left"></div>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <div>
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    采购退货单
                </h1>
                <ol class="breadcrumb">
                    <li><a href="/index"><i class="fa fa-dashboard"></i> 首页</a></li>
                    <li><a href="#">采购</a></li>
                    <li class="active">采购退货单</li>
                </ol>
            </section>
            <!-- Main content -->
            <section class="content">
                <div class="col-md-3">
                    <!--左上方导航-->
                    <div class="box box-primary">
                        <div class="box-header">
                            <ul class="nav nav-pills">
                                <li class="active"><a href="#all" data-toggle="tab">全部</a></li>
                                <li><a href="#draft" data-toggle="tab">草稿</a></li>
                                <li><a href="#ready-purchase" data-toggle="tab">已转退货单</a></li>
                            </ul>
                        </div>
                        <form>
                            <div class="box-body">
                                <!-- Date range -->
                                <div class="form-group">
                                    <!-- select -->
                                    <div class="form-group">
                                        <label>供应商</label>
                                        <select class="form-control select2">
                                            <option>--请选择--</option>
                                            <option th:each="supplier:${supplier}" th:text="${supplier.name}" th:value="${supplier.id}"></option>
                                        </select>
                                    </div>
                                    <!--日期选择-->
                                    <div class="form-group">
                                        <label>日期</label>
                                        <div class="input-group">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <textarea class="calendar-item" id="start"></textarea>
                                            <p style="position: absolute;margin-left:120px;font-size: 1.2em">至</p>
                                            <textarea style="margin-left:161px;" class="calendar-item" id="end"></textarea>
                                        </div>
                                    </div>
                                    <!-- /.input group -->
                                    <label>单号</label>
                                    <div class="input-group input-group-sm">
                                        <input type="text" class="form-control">
                                        <span class="input-group-btn">
                                             <button type="button" class="btn btn-info btn-flat">查询</button>
                                            </span>
                                    </div>
                                    <!-- /.input group -->
                                </div>
                                <!-- /.form group -->
                            </div>
                            <!-- /.box-body -->
                        </form>

                    </div>
                    <!--左下方表格-->
                    <div class="box">
                        <div class="box-header with-border">
                        </div>
                        <!-- /.box-header -->
                        <form>
                            <div class="box-body">
                                <div class="tab-content">
                                    <div class="tab-pane active" id="all">
                                        <table class="table table-bordered">
                                            <tr>
                                                <th>供应商名称</th>
                                                <th>日期</th>
                                                <th style="width: 40px">状态</th>
                                            </tr>
                                            <tr>
                                                <td>1</td>
                                                <td>2019-05-17 16:11</td>
                                                <td><span class="badge bg-green">已经盘点</span></td>
                                            </tr>
                                            <tr>
                                                <td>2</td>
                                                <td>2019-05-17 16:12</td>
                                                <td><span class="badge bg-yellow">草稿</span></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <div class="tab-pane" id="draft">
                                        <table class="table table-bordered">
                                            <tr>
                                                <th>供应商名称</th>
                                                <th>日期</th>
                                                <th style="width: 40px">状态</th>
                                            </tr>
                                            <tr>
                                                <td>1</td>
                                                <td>2019-05-17 16:12</td>
                                                <td><span class="badge bg-yellow">草稿</span></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <div class="tab-pane" id="ready-purchase">
                                        <table class="table table-bordered">
                                            <tr>
                                                <th>供应商名称</th>
                                                <th>日期</th>
                                                <th style="width: 40px">状态</th>
                                            </tr>
                                            <tr>
                                                <td>1</td>
                                                <td>2019-05-17 16:11</td>
                                                <td><span class="badge bg-green">已经盘点</span></td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->
                            <div class="box-footer clearfix">
                                <ul class="pagination pagination-sm no-margin pull-right">
                                    <li><a href="#">&laquo;</a></li>
                                    <li><a href="#">1</a></li>
                                    <li><a href="#">2</a></li>
                                    <li><a href="#">3</a></li>
                                    <li><a href="#">&raquo;</a></li>
                                </ul>
                            </div>
                        </form>

                    </div>
                    <!-- /.box -->
                </div>
                <div class="col-md-9">
                    <div class="box">
                        <div class="box-header">
                            <h2 class="box-title">采购退货单 </h2>
                            <div style="float: right ;margin-right:8px">
                                <button type="button" class="btn btn-block btn-info">
                                    <扫码></扫码>
                                </button>
                            </div>
                            <div style="float: right ;margin-right:8px">
                                <button type="button" class="btn btn-info"><a href="/purchase/list" style="color: white">新增退货单</a></button>
                            </div>
                        </div>
                        <hr/>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <span style="font-size: 1.3em">尚欠供应商款:</span>
                            <!--<span style="font-size: 2.5em;color: red;" th:text="￥+${amount}"></span>-->
                            <div class="form-group" style="padding-top: 20px">
                                <label style="color: red;margin-left: 10px;float: left">*</label><label style="float: left">供应商选择:</label>
                                <select class="form-control" style="width: 200px;float: left;margin-left: 10px;margin-top: -5px">
                                    <option>--请选择--</option>
                                    <option th:each="supplier:${supplier}" th:text="${supplier.name}" th:value="${supplier.id}"></option>
                                </select>
                                <label style="color: red;margin-left: 10px;float: left">*</label><label style="float: left">仓库选择:</label>
                                <select class="form-control" style="width: 200px;float: left;margin-left: 10px;margin-top: -5px">
                                    <option>== 请选择 ==</option>
                                    <option th:each="storeHouses:${storeHouses}" th:text="${storeHouses.storeName}" th:value="${storeHouses.storeId}"></option>
                                </select>
                                <label style="margin-left: 10px;float: left">结算账户:</label>
                                <select class="form-control" style="width: 200px;float: left;margin-left: 10px;margin-top: -5px">
                                    <option>== 请选择 ==</option>
                                    <option>柜台现金</option>
                                    <option>平安卡</option>
                                    <option>支付宝</option>
                                </select>
                                <label style="margin-left: 10px;float: left">实付金额:</label>
                                <input type="tel" style="width: 100px;height: 34px;float: left;margin-left: 10px;margin-top: -5px" class="capital mui-input-clear" value="0.00">
                            </div>
                            <div class="form-group" style="padding-left: auto;padding-top: 30px">
                                <label style="margin-left: 10px;">备注:</label><input type="text" style="width: 40%;margin-left: 10px;height:34px">
                                <label  style="margin-left: 100px">日期:</label><textarea style="margin-left: 10px;height:34px" class="calendar-item" id="center"></textarea>

                            </div>
                            <div class="col-md-6 col-md-offset-3">
                                <div class="form-group">
                                    <label>请选择你要采购的商品</label>
                                    <select class="form-control select2" style="width: 100%;" id="goodsOption" >
                                        <option style='display: none'></option>
                                        <option th:each="goods:${good}" th:text="${goods.name}" th:value="${goods.barCode}"></option>
                                    </select>
                                </div>
                            </div>
                            <table id="mainTable" class="display" cellspacing="0" width="100%">
                                <thead>
                                <tr>
                                    <th>商品</th>
                                    <th>货号</th>
                                    <th>条码</th>
                                    <th>颜色</th>
                                    <th>尺码</th>
                                    <th>数量</th>
                                    <th>单价</th>
                                    <th>折扣(%)</th>
                                    <th>折后价</th>
                                    <th>金额</th>
                                    <th>折后金额</th>
                                </tr>
                                </thead>
                                <tbody >
                                </tbody>
                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
            </section>
            <!-- /.content -->
        </div>
    </div>
    <!-- /.content-wrapper -->
    <footer class="main-footer">
        <div class="pull-right hidden-xs">
            <b>Version</b> 2.4.0
        </div>
        <strong>Copyright &copy; 2014-2016 <a href="https://adminlte.io">Almsaeed Studio</a>.</strong> All rights
        reserved.
    </footer>
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Create the tabs -->
        <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
            <li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
            <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
            <!-- Home tab content -->
            <div class="tab-pane" id="control-sidebar-home-tab">
                <h3 class="control-sidebar-heading">Recent Activity</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-birthday-cake bg-red"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Langdon's Birthday</h4>

                                <p>Will be 23 on April 24th</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-user bg-yellow"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>

                                <p>New phone +1(800)555-1234</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-envelope-o bg-light-blue"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>

                                <p>nora@example.com</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-file-code-o bg-green"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>

                                <p>Execution time 5 seconds</p>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

                <h3 class="control-sidebar-heading">Tasks Progress</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Custom Template Design
                                <span class="label label-danger pull-right">70%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-danger" style="width: 70%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Update Resume
                                <span class="label label-success pull-right">95%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-success" style="width: 95%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Laravel Integration
                                <span class="label label-warning pull-right">50%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-warning" style="width: 50%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Back End Framework
                                <span class="label label-primary pull-right">68%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-primary" style="width: 68%"></div>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

            </div>
            <!-- /.tab-pane -->
            <!-- Stats tab content -->
            <div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
            <!-- /.tab-pane -->
            <!-- Settings tab content -->
            <div class="tab-pane" id="control-sidebar-settings-tab">
                <form method="post">
                    <h3 class="control-sidebar-heading">General Settings</h3>

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Report panel usage
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Some information about this general settings option
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Allow mail redirect
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Other sets of options are available
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Expose author name in posts
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Allow the user to show his name in blog posts
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <h3 class="control-sidebar-heading">Chat Settings</h3>

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Show me as online
                            <input type="checkbox" class="pull-right" checked>
                        </label>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Turn off notifications
                            <input type="checkbox" class="pull-right">
                        </label>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Delete chat history
                            <a href="javascript:void(0)" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
                        </label>
                    </div>
                    <!-- /.form-group -->
                </form>
            </div>
            <!-- /.tab-pane -->
        </div>
    </aside>
    <div class="control-sidebar-bg"></div>
    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="myModal">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="gridSystemModalLabel"></h4>
                </div>
                <div class="modal-body">
                    <table id="twoDisTable" class="table table-bordered table-condensed" cellspacing="0" width="100%">
                        <thead>
                        <tr id="mTh">
                            <th></th>
                        </tr>
                        </thead>
                        <tbody id="myBody">
                        </tbody>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="twoDisTableSubmit">提交</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->
<script src="../../bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="../../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Select2 -->
<script src="../../bower_components/select2/dist/js/select2.full.min.js"></script>
<!-- InputMask -->
<script src="../../plugins/input-mask/jquery.inputmask.js"></script>
<script src="../../plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="../../plugins/input-mask/jquery.inputmask.extensions.js"></script>
<!-- date-range-picker -->
<script src="../../bower_components/moment/min/moment.min.js"></script>
<script src="../../bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap datepicker -->
<!-- bootstrap color picker -->
<!-- bootstrap time picker -->
<script src="../../plugins/timepicker/bootstrap-timepicker.min.js"></script>
<!-- SlimScroll -->
<script src="../../bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- iCheck 1.0.1 -->
<script src="../../plugins/iCheck/icheck.min.js"></script>
<!-- FastClick -->
<script src="../../bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="../../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../dist/js/demo.js"></script>
<!-- DataTables -->
<script src="../../bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="../../bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!-- FastClick -->
<!-- page script -->
<script src="../../dist/js/datePicker.js"></script>
<script type="text/javascript">
    Calendar.create({
        classN: 'calendar-item',
        callBack: function (bindElem, dateObj) {
            bindElem.innerHTML = dateObj.year + '-' + dateObj.month + '-' + dateObj.date;
        }
    })
    //只能输入数字金额，且限定为2位
    var precapital;
    document.querySelector('.capital').addEventListener('focus', function() {
        if (this.value == '0.00') {
            this.value = '';
        } else {
            this.value = this.value.replace(/\.00/, '').replace(/(\.\d)0/,'$1');
        }
        precapital = this.value;
    });
    document.querySelector('.capital').addEventListener('keyup', function() {

        this.value = this.value.replace(/^[\.]/, '').replace(/[^\d.]/g, '');
        if (this.value.split(".").length - 1 > 1) {
            this.value = precapital;
        }
        precapital = this.value;
    });
    document.querySelector('.capital').addEventListener('blur', function() {
        this.value = this.value.replace(/[\.]$/, '');
        this.value = this.value.replace(/(.*)\.([\d]{2})(\d*)/g,'$1.$2');
        this.value = Number(this.value).toFixed(2);
        var logNum = this.value.toString();
        if(logNum.match(/\./g) != null){
            integerNum = parseInt(logNum).toString().replace(/\d(?=(\d{3})+$)/g,'$&,');
            decimalNum = '.' + logNum.replace(/(.*)\.(.*)/g,'$2');
            document.querySelector(".logbox").innerHTML = integerNum+decimalNum;
        }else{
            document.querySelector(".logbox").innerHTML = logNum.replace(/\d(?=(\d{3})+$)/g,'$&,');
        }
    });
</script>
<script>
    //商品对应尺寸
    var currentSizes =[];
    //商品对应颜色
    var currentColors = [];
    //二维输入表格
    var twoDisTable;
    //调拨表格
    var mainTable;
    //左边表格
    var leftTable;
    //选中的商品条码
    var selectBarCode;
    //调拨单表单
    var dataForm;

    $('.select2').select2();
    $(function(){
        $("#goodsOption").change(function () {
            if(twoDisTable!=null){
                //重置
                twoDisTable.destroy();
                twoDisTable=null;
                $("#mTh th").remove();
                $("#mTh").append("<th></th>")
                $("#myBody tr").remove();
            }
            var barCode = $(this ).val();
            if(!barCode){//判断是否为空{}
                alert("商品条码为空");
                return false;
            }
            //显示商品名字
            var text = $('#goodsOption option:selected').text();
            $("#gridSystemModalLabel").text(text);
            $.ajax({
                type:"GET",
                url:"/requisition_note/getGoodsInfo",
                data: {
                    barCode:barCode
                },
                success:function (response) {
                    var data = response.data;
                    selectBarCode = data.barCode
                    currentSizes = data.sizes;
                    currentColors = data.colors;
                    if(currentSizes.length == 0){
                        alert("商品没有可用的尺码！");
                        return false;
                    }
                    if(currentColors.length == 0){
                        alert("商品没有可用的颜色！");
                        return false;
                    }
                    var sizeThTemp = "";
                    var colorBodyTemp = "";
                    //构建颜色
                    $.each(currentColors,function (index,value) {
                        colorBodyTemp +="<tr><td>"+value.name+"</td>";
                        for (i = 0 ; i<currentSizes.length ; i++ ){
                            //使用中间量 使字符串对象可以有特殊符号如""
                            var temp = "<td><input type= \"number\" style=\"width:100%\" align=\"right\" min='1' name =\"setNumber\"></td>";
                            colorBodyTemp+=temp;
                        }
                        colorBodyTemp+="</tr>";
                    });
                    //构建尺码
                    $.each(currentSizes,function (i,v) {
                        var temp = "<th class=\"text-center\">"+v.name+"</th>";
                        sizeThTemp +=temp
                    });
                    $("#myBody").append(colorBodyTemp);
                    $("#mTh").append(sizeThTemp);

                    //二维输入表格 在Ajax 结束前重置表格
                    twoDisTable = $('#twoDisTable').DataTable({
                        searching: false,
                        bLengthChange: false,
                        paging:false,
                        ordering:  false
                    });
                    //显示二维选择表格
                    $("#myModal").modal('show');
                }
            })
            return 0;
        })
    })
    //生成调拨单
    $(function () {
        $("#twoDisTableSubmit").click(function () {
            var orderDTO;
            var goods = new Array();
            var temp = 0;
            var data = twoDisTable.$("input").toArray();
            for(i = 0 ; i<currentColors.length ; i++){
                var color = currentColors[i];
                for(j = 0 ; j<currentSizes.length;j++){
                    var size = currentSizes[j];
                    if(data[temp].value !=""){
                        var good = {
                            sizeId : size.id,
                            colorId : color.id,
                            sizeName:size.name,
                            colorName:color.name,
                            goodQuantity : data[temp].value
                        };
                        goods.push(good);
                    }
                    temp++;

                }
            }
            orderDTO ={
                openid:"fdasdasfsadfsdaurn",
                goodsBarCode:selectBarCode,
                orderDetailList:goods
            }
            if(mainTable!=null){
                //重置
                mainTable.destroy();
                mainTable=null;
            }
            mainTable = $('#mainTable').DataTable({
                'paging'      : true,
                'lengthChange': false,
                'searching'   : true,
                'ordering'    : true,
                'info'        : true,
                'autoWidth'   : false,
                "scrollY": 200,
                "scrollX": true,
                ajax:{
                    "url":"/requisition_note/purchaseList",
                    "type":"post",
                    "contentType" : "application/json",
                    "data":  function () {
                        return JSON.stringify( orderDTO );
                    },
                    "dataType":"json",
                    "dataSrc":function (result) {
                        if(result.msg=="success"){
                            alert("成功生成调拨单在表格中,没有库存的已经发送信息给指定账户进行补货,请确定。" +
                                "如果表格没有商品说明选择调拨的商品都没有仓库可以调拨。")
                            $("#myModal").modal('hide');
                            dataForm = result.data.valueOf();
                            return result.data;
                        }else {
                            alert(result.msg);
                            window.location.reload();
                        }
                    }
                },
                "columns": [
                    { "data": "orderMaster.goodsName" },
                    { "data": "orderDetail.goodId" },
                    { "data": "orderMaster.goodsBarCode" },
                    { "data": "orderDetail.colorName" },
                    { "data": "orderDetail.sizeName"},
                    { "data": "orderDetail.goodQuantity"},
                    { "data": "orderDetail.goodPrice"},
                    { "data": "orderDetail.discount"},
                    { "data": "orderDetail.goodPrice" * "orderDetail.discount"},
                    { "data": "orderDetail.goodPrice" * "orderDetail.goodQuantity"},
                    { "data": "orderDetail.goodPrice" * "orderDetail.goodQuantity" * "orderDetail.discount"}
                ]
            });
            return 0;
        });
    })
    $("#submitForm").click(function () {
        if(dataForm.length != 0){
            $.ajax({
                url:"/requisition_note/determine",
                type:"POST",
                contentType :"application/json",
                data :JSON.stringify( dataForm ),
                dataType:"json",
                success:function (result) {
                    if(result.code==1){
                        alert("已经申请调拨和进行补货");
                        window.location.reload();
                    }else {
                        alert(result.msg);
                    }
                },

            })
        }else {
            alert("无可以保存的商品单");
        }
    })
    $("#submitDraft").click(function () {
        if(dataForm.length != 0){
            $.ajax({
                url:"/requisition_note/draft",
                type:"POST",
                contentType :"application/json",
                data :JSON.stringify( dataForm ),
                dataType:"json",
                success:function (result) {
                    if(result.code==1){
                        alert("已经存入草稿");
                        window.location.reload();
                    }else {
                        alert(result.msg);
                    }
                },

            })
        }else {
            alert("无可以保存的商品单");
        }
    })

    //点击表格触发触发事件
    $('#leftTable tbody').on('click', 'tr', function () {
        var table = $('#leftTable').DataTable();
        var data = table.row( this ).data();
        var orderId = data[0];
        alert(orderId);
    } );
</script>
</body>
</html>